package com.agentai.framework.operatelog.service;

import com.agentai.framework.common.cache.RedisService;
import lombok.AllArgsConstructor;
import com.agentai.framework.common.cache.RedisKeys;
import com.agentai.framework.operatelog.dto.OperateLogDTO;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.time.temporal.ChronoUnit;

/**
 * 操作日志服务
  */
@Service
@AllArgsConstructor
public class OperateLogService {
    private final RedisService redisService;

    @Async
    public void saveLog(OperateLogDTO log) {
        String key = RedisKeys.getLogKey();

        // 保存到Redis队列
        redisService.leftPush(key, log, RedisService.NOT_EXPIRE, ChronoUnit.MINUTES);
    }
}
